<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">

      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="4" :sm="6">
            <a-form-item :label=" $t('light.lightCode') ">
              <j-input :placeholder=" $t('base.inputVagueQuery') " v-model="queryParam.ligCode101"></j-input>
            </a-form-item>
          </a-col>


          <a-col :md="4" :sm="8">
            <a-form-item :label=" $t('light.gateWay') ">
              <j-input :placeholder=" $t('base.inputVagueQuery') " v-model="queryParam.gataWayCode101"></j-input>
            </a-form-item>
          </a-col>

          <a-col :md="4" :sm="8">
            <a-form-item :label="$t('base.createTime')">
              <a-month-picker
                :placeholder="$t('base.pleaseChoose')"
                v-model="monthModelValue"
                @change="monthChange"
              />
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search"> {{$t('base.query')}} </a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px"> {{$t('base.reset')}} </a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>

    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <img :src="getAvatarView(record.currentWorkStatus)"/>
          </div>
        </template>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>



      </a-table>
    </div>

  </a-card>
</template>

<script>
  import Bar from '@/components/chart/Bar'
  import Pie from '@/components/chart/Pie'
  import ACol from 'ant-design-vue/es/grid/Col'
  import { getAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import { httpAction } from '@/api/manage'
  import JDate from '@/components/jeecg/JDate'
  import { validateDuplicateValue,filterObj } from '@/utils/util'
  import moment from 'moment'//导入文件

  export default {
    name: 'GlrLightDataMonth',
    mixins:[JeecgListMixin],
    components: {
      ACol,
      Bar,
      Pie,
      JInput,
      JDate,
    },
    data() {
      return {
        description: this.$t('statisticalReport.monthElectricityStatistics'),
        disableMixinCreated:true,
        // 查询条件
        queryParam: {},
        monthModelValue:moment(),
        monthValue: [],
        // 表头
        columns: [
          {
            title:this.$t('base.createTime'),
            align:"center",
            dataIndex: 'create_date11'
          },
          {
            title: this.$t('light.gateWay'),
            align: "center",
            dataIndex: 'gata_way_code'
          },
          {
            title: this.$t('light.gateWayName') ,
            align: "center",
            dataIndex: 'gateway_name'
          },
          {
            title: this.$t('statisticalReport.monthElectricityKWH') ,
            align:"center",
            dataIndex: 'day_electricity'
          },
          {
            title:this.$t('statisticalReport.monthEconomyElectricityKWH')  ,
            align:"center",
            dataIndex: 'day_economy_electricity'
          },
          {
            title:this.$t('statisticalReport.yearElectricityKWH') ,
            align:"center",
            dataIndex: 'total_day_electricity'
          },
          {
            title: this.$t('statisticalReport.yearEconomyElectricityKWH') ,
            align:"center",
            dataIndex: 'total_day_economy_electricity'
          }
        ],
        url: {
          list:"/glr/glrLightData/datagridLightReportChart",
        },
      }
    },
    created() {
      this.queryParam.ligCode = "";
      this.queryParam.gataWayCode = "";
      this.monthModelValue=moment();
      this.queryParam.dateTime=this.monthModelValue;
      this.monthValue=moment(new Date()).format("YYYY-MM")
      this.loadData();
      //this.loadDate(this.url.lightReportChart,'year',{ligCode:'',gatawayCode:'',yearMonth:this.monthValue});
    },
    methods: {
      getQueryParams() {
        //获取查询条件
        let sqp = {}
        if(this.superQueryParams){
          sqp['superQueryParams']=encodeURI(this.superQueryParams)
        }
        this.queryParam.ligCode = this.queryParam.ligCode101;
        this.queryParam.gataWayCode = this.queryParam.gataWayCode101;
        var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
        param.field = this.getQueryField();
        param.columnId = this.columnId;
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        return filterObj(param);
      },
      searchReset(){
        this.queryParam.ligCode = "";
        this.queryParam.gataWayCode = "";
        this.queryParam.ligCode101 = "";
        this.queryParam.gataWayCode101 = "";
        this.monthModelValue=moment();
        this.queryParam.dateTime =this.monthModelValue;
        this.loadData(this.ipagination.current);
      },
      // 选择月份日期
      monthChange(value, mode) {
        this.monthValue = mode
        this.queryParam.dateTime =this.monthModelValue;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
  .ant-card-body .table-operator {
    margin-bottom: 18px;
  }

  .ant-table-tbody .ant-table-row td {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .anty-row-operator button {
    margin: 0 5px
  }

  .ant-btn-danger {
    background-color: #ffffff
  }

  .ant-modal-cust-warp {
    height: 100%
  }

  .ant-modal-cust-warp .ant-modal-body {
    height: calc(100% - 110px) !important;
    overflow-y: auto
  }

  .ant-modal-cust-warp .ant-modal-content {
    height: 90% !important;
    overflow-y: hidden
  }

  .statistic {
    padding: 0px !important;
    margin-top: 50px;
  }

  .statistic h4 {
    margin-bottom: 20px;
    text-align: center !important;
    font-size: 24px !important;;
  }

  .statistic #canvas_1 {
    width: 100% !important;
  }
</style>